function [post act] = kmeanspostBayes(mix, data)


K = mix.ncentres;
N = size(data.Y, 1);

[act logact] = kmeansactivBayes(mix, data);
if isfield(mix.varprior, 'a0')
    log_priors = dirichletln_exp(mix.varposterior.a);
else
    log_priors = log(mix.priors);
end

logpost = ones(N, 1)*log_priors + logact;
max_logpost = max(logpost, [], 2);
logpost = logpost - max_logpost*ones(1, K);

post = exp(logpost);
post = post./(sum(post, 2)*ones(1, K));
